//
//  WSDelUserAlter.m
//  CharonTVProject
//
//  Created by karong on 2023/8/18.
//

#import "WSDelUserAlter.h"
#import "WSGradientColorButton.h"

@interface WSDelUserAlter ()
@property (nonatomic, assign) NSInteger seconds;
@property (nonatomic, strong) NSTimer *timer;
@end

@implementation WSDelUserAlter
- (void)viewDidLoad {
    [super viewDidLoad];
    
}

- (void)layoutView {
    [super layoutView];
    self.confirmBtn.userInteractionEnabled = NO;
    [self startTime];
}

- (void)startTime {
    [((WSGradientColorButton *)self.confirmBtn) resetCorlor1:UIColor.bg_gray_f2f2f2 color2:UIColor.bg_gray_f2f2f2];
    [self.confirmBtn setTitleColor:UIColor.font_gray_999999 forState:(UIControlStateNormal)];
    self.seconds = 5;
    [self.confirmBtn setTitle:WSSF(@"%@(%ld)", self.confirmStr, self.seconds) forState:(UIControlStateNormal)];
    self.timer = [NSTimer scheduledTimerWithTimeInterval:1.0f target:self selector:@selector(countdown) userInfo:nil repeats:YES];
}

- (void)countdown {
    self.seconds -- ;
    [self.confirmBtn setTitle:WSSF(@"%@(%ld)", self.confirmStr, self.seconds) forState:(UIControlStateNormal)];
    if(self.seconds <= 0) {
        // 倒计时结束
        [self skipStartScreenWithTrigger];
    }
}

- (void)skipStartScreenWithTrigger {
    [self.timer invalidate];
    self.timer = nil;
    self.confirmBtn.userInteractionEnabled = YES;
    [self.confirmBtn setTitle:WSSF(@"%@", self.confirmStr) forState:(UIControlStateNormal)];
    [((WSGradientColorButton *)self.confirmBtn) resetCorlor1:[UIColor colorFromHexRGB:@"FFD962"] color2:[UIColor colorFromHexRGB:@"FBBB34"]];
    [self.confirmBtn setTitleColor:UIColor.font_white_ffffff forState:(UIControlStateNormal)];
}
@end
